﻿using System;

namespace Simple3DRedactor.Domain
{
    [Serializable]
    public class Cylinder : Geometry
    {
        public Cylinder()
        {
            Name = "Cylinder";
            BaseRadius = TopRadius = Height = 1.0f;
            Slices = 50;
            Stacks = 50;
        }

        private float _baseRadius;
        public float BaseRadius
        {
            get { return _baseRadius; }
            set
            {
                if (Math.Abs(_baseRadius - value) > float.Epsilon)
                {
                    _baseRadius = value;
                    OnChange();
                }
            }
        }

        private float _topRadius;
        public float TopRadius
        {
            get { return _topRadius; }
            set
            {
                if (Math.Abs(_topRadius - value) > float.Epsilon)
                {
                    _topRadius = value;
                    OnChange();
                }
            }
        }

        private float _height;
        public float Height
        {
            get { return _height; }
            set
            {
                if (Math.Abs(_height - value) > float.Epsilon)
                {
                    _height = value;
                    OnChange();
                }
            }
        }

        private int _slices;
        public int Slices
        {
            get { return _slices; }
            set
            {
                if (_slices != value)
                {
                    _slices = value;
                    OnChange();
                }
            }
        }

        private int _stacks;
        public int Stacks
        {
            get { return _stacks; }
            set
            {
                if (_stacks != value)
                {
                    _stacks = value;
                    OnChange();
                }
            }
        }

        public override TV CreateView<TV>(IObjectViewFactory<TV> factory)
        {
            return factory.Create(this);
        }
    }
}
